Page({
  data: {
    avatar_url: '/pages/static/default.jpg',
    nickname: '匿名用户',
  },
  onLoad(options) {
    // 页面加载时的逻辑
  },
  onShow() {
    this.getUserInfo();
  },
  // ... 其他生命周期函数 ...

  // 获取用户信息
  getUserInfo() {
    let that = this;
    wx.getStorage({
      key: 'userInfo',
      success: function(res) {
        that.setData({
          avatar_url: res.data.avatarUrl,
          nickname: res.data.nickName
        });
      }
    });
  },
  // 存储用户信息
  saveUserInfo() {
    wx.setStorage({
      key: 'userInfo',
      data: {
        avatarUrl: this.data.avatar_url,
        nickName: this.data.nickname
      }
    });
  },
  // 事件处理函数
  navigateToAnotherPage: function() {
    wx.redirectTo({
      url: '/pages/category/category' // 指定要跳转的页面路径，不需要文件扩展名
    });
  },
  // ... 其他事件处理函数 ...
  data: {
    categories: []
  },
  onLoad: function() {
    this.loadCategories();
  },
  loadCategories: function() {
    const app = getApp();
    this.setData({
      categories: wx.getStorageSync('categories') || app.globalData.categories
    });
  },
  deleteCategory: function(e) {
    const index = e.currentTarget.dataset.index;
    const app = getApp();
    app.globalData.categories.splice(index, 1);
    wx.setStorageSync('categories', app.globalData.categories);
    this.setData({
      categories: app.globalData.categories
    });
  }
});
// category-list.js
